<!--<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>代言家庭信息修改页面</title>-->
#@layout()

#define css()
<!--全局样式-->
<style type="text/css">
    #body {
        background-image: url(http://47.105.208.60:8080/wechat-api/images/loginbg.png);
        background-position: center center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
    }

    form#index {
        margin-left: auto;
        margin-right: auto;
        max-width: 500px;
        background: #F7F7F7;
        opacity: 0.95;
        padding: 25px 15px 25px 10px;
        font: 12px Georgia, "Times New Roman", Times, serif;
        color: #888;
        text-shadow: 1px 1px 1px #FFF;
        border: 1px solid #E4E4E4;
        text-align: center;
    }

    form#index h3 {
        font-size: 25px;
        padding: 0px 0px 10px 40px;
        display: block;
        border-bottom: 1px solid #E4E4E4;
        margin: -10px -15px 30px -10px;;
        color: #888;
        text-align: center;
    }

    form#index label {
        display: block;
        margin: 0px;
    }

    form#index label > span {
        float: left;
        width: 20%;
        text-align: right;
        padding-right: 10px;
        margin-top: 10px;
        color: #888;
    }

    form#index input[type="text"], form#index input[type="number"] {
        border: 1px solid #DADADA;
        color: #888;
        height: 30px;
        margin-bottom: 16px;
        margin-right: 6px;
        margin-top: 2px;
        outline: 0 none;
        padding: 3px 3px 3px 5px;
        width: 70%;
        font-size: 12px;
        line-height: 15px;
        box-shadow: inset 0px 1px 4px #ECECEC;
        -moz-box-shadow: inset 0px 1px 4px #ECECEC;
        -webkit-box-shadow: inset 0px 1px 4px #ECECEC;
    }

    form#index .button {
        background: #E27575;
        border: none;
        padding: 10px 25px 10px 25px;
        color: #FFF;
        box-shadow: 1px 1px 5px #B6B6B6;
        border-radius: 3px;
        text-shadow: 1px 1px 1px #9E3F3F;
        cursor: pointer;
    }

    form#index label .container {
        width: 300px;
        height: 30px;
        background-color: greenyellow;
        margin-left: auto;
        margin-right: auto;

    }

    form#index label > span #progress {
        height: 20px;
        background-color: darkgray;
        display: inline-block;
        padding: 3px 0 0 0;
    }

</style>
#end

#define script()
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>

<script type="text/javascript"
        src="https://cdn.bootcss.com/jquery.serializeJSON/2.9.0/jquery.serializejson.js"></script>

<script>

    function onLoadByPage() {
        //后台查询数据
        var url="http://47.105.208.60:8080/wechat-api/file/file/findEndorsementinfoById";

        //var url = "http://localhost:8080/wechat-api/file/findEndorsementinfoById";
        var objData = {"id": "#(id ??)"}
        $.ajax({
            url: url,
            data: objData,
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                var msg = data.info;
                console.log("+++++++++")
                console.log(data)
                document.getElementById("id").value = msg.id;
                document.getElementById("eid").value = msg.eid;
                //获取eid查询图片
                findFile(msg.eid);

                document.getElementById("name").value = msg.name;
                document.getElementById("address").value = msg.address;
                document.getElementById("longitude").value = msg.longitude;
                document.getElementById("latitude").value = msg.latitude;

                console.log(msg.etype);
                $('input:checkbox').each(function (index, domEle) {
                    console.log(domEle)
                    var inputclients = domEle.value;
                    var clients = data.etype.split(",");
                    console.log(inputclients + "111")

                    for (var j = 0; j < clients.length; j++) {
                        if (inputclients == clients[j]) {
                            console.log(clients[j] + "22222");

                            domEle.checked = true;
                        }
                    }

                });


                document.getElementById("summary").value = msg.summary;
                document.getElementById("video").value = msg.video;
                document.getElementById("report").value = msg.report;
                document.getElementById("username").value = msg.username;
                document.getElementById("userphone").value = msg.userphone;

            }, error: function (err) {
                console.log("----------")
                console.log(err)
            }
        });

    }

    onLoadByPage();


    //查询图片
    function findFile(isVal) {
        console.log(isVal + "=-=-=-=-=-=-=-")
        $.ajax({
            //url: "http://localhost:8080/wechat-api/file/findFile",
            url: "http://47.105.208.60:8080/wechat-api/file/findFile",

            data: [
                {name: 'eid', value: isVal}
            ],
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                console.log("+++++++")
                console.log(data)
                var infos = data.info
                var contentArr = '';
                if (infos != '') {
                    for (var index in infos) {
                        var id = infos[index].id;
                        var eid = infos[index].eid;
                        var picture = infos[index].picture;
                        var shouming = infos[index].shouming;
                        console.log(id + "," + eid)
                        var content = "<label id='tr-" + index + "' class='tr'>" +
                            " <input type='text'  value='" + id + "' style='display: none'/> " +
                            " <input type='text'  value='" + eid + "' style='display: none'/><br>" +
                            "<img src='" + picture + "' style='width: 300px;height: 200px'/><br />" +
                            " <input type='text' value='" + shouming + "'/>" +
                            "<input type='button' value='删除' onclick='shanchu(" + id + ")'/>" +
                            "<input type='button' value='排序' onclick='paixu(" + id + ")'/>" +
                            "</label>";
                        contentArr += content
                    }
                    document.getElementById("label").innerHTML = contentArr;
                }

            }, error: function (err) {
                console.log("----------")
                console.log(err)
            }
        });

    }

    //点击放大缩小图片

    /*  $(function () {
        $('#img').dblclick(function () {
            $(this).toggleClass('min');
            $(this).toggleClass('max');
        });
    });*/

    //删除图片
    function shanchu(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/file/updateFile",
            //url: "http://localhost:8080/wechat-api/file/updateFile",
            data: [
                {name: 'id', value: id}
            ],
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                console.log("+++++++")
                console.log(data)

                window.location.reload();

            }, error: function (err) {
                console.log("----------")
                console.log(err)
            }
        });

    }

    //修改图片排序
    function paixu(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/file/updateFlag",
            //url: "http://localhost:8080/wechat-api/file/updateFlag",
            data: [
                {name: 'id', value: id}
            ],
            dataType: 'json',
            type: 'POST',
            success: function (data) {
                console.log("+++++++")
                console.log(data)

                window.location.reload();

            }, error: function (err) {
                console.log("----------")
                console.log(err)
            }
        });

    }


    //图文上传
    function shangchuan() {
        window.open("#(CPATH)/admin/home/select", "window", "height=300, width=600, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
    }

    //代言家庭保存修改的信息

    function baocun() {
        var obj = document.getElementsByName("etype");

        var val = [];

        for (var k = 0; k < obj.length; k++) {
            if (obj[k].checked) {
                val.push(obj[k].value)

            }
        }
        console.log(val)

        var eee = val.join(',');

        var array = {
            id: document.getElementById("id").value,
            eid: document.getElementById("eid").value,
            name: document.getElementById("name").value,
            address: document.getElementById("address").value,
            longitude: document.getElementById("longitude").value,
            latitude: document.getElementById("latitude").value,
            summary: document.getElementById("summary").value,
            etype: eee,
            video: document.getElementById("video").value,
            report: document.getElementById("report").value,
            username: document.getElementById("username").value,
            userphone: document.getElementById("userphone").value
        };
        console.log(array);
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/file/updateEndorsementinfoById",
            //url: "http://localhost:8080/wechat-api/file/updateEndorsementinfoById",
            data:
                JSON.stringify(array),

            //JSON.stringify($('#index').serializeJSON()),

            type: 'POST',
            dataType: "json",
            contentType: "application/json",
            success: function (data) {
                console.log("+++++++++")
                console.log(data)
                alert("提交成功")
                document.getElementById("index").reset();

                window.location.href = "#(CPATH)/admin/home/a";

            }, error: function (err) {
                console.log("----------")
                console.log(err)
                alert("提交失败")
            }
        });

    }

</script>
#end
<!--</head>
<body>-->
#define content()
<div id="body" class="content-wrapper">
    <form id="index" onsubmit="return false" action="##" method="post">
        <h3 style="align-content: center">代言家庭信息修改页</h3>

        <label>
            <input type="text" name="id" class="id" id="id" style="display: none">
        </label>
        <label>
            <span>农户编号: </span>
            <input type="text" name="eid" class="eid" id="eid">
        </label>
        <label>
            <span>农户名称:</span>
            <input type="text" name="name" class="name" id="name">
        </label>
        <label>
            <span>农户所属乡镇:</span>
            <input type="text" name="address" class="address" id="address">
        </label>
        <label>
            <span>经度:</span>
            <input type="text" name="longitude" class="longitude" id="longitude">
        </label>
        <label>
            <span>纬度:</span>
            <input type="text" name="latitude" class="latitude" id="latitude">
        </label>
        <label>
            <span>类型:</span>

            <input type="checkbox" name="etype" value="佛系人家" id="etype1">佛系人家
            <input type="checkbox" name="etype" value="健身人家" id="etype2">健身人家
            <input type="checkbox" name="etype" value="农林人家" id="etype3">农林人家<br>
            <input type="checkbox" name="etype" value="文艺人家" id="etype4">文艺人家
            <input type="checkbox" name="etype" value="手艺人家" id="etype5">手艺人家
            <input type="checkbox" name="etype" value="土味人家" id="etype6">土味人家<br>

        </label><br>
        <label>
            <span>简介:</span>
            <input type="text" name="summary" class="summary" id="summary">
        </label>


        <label id="label" class="label">
            <span>图片展示:</span>

        </label>


        <label>
            <span>图文上传:</span>
            <input type="button" value="点击上传" onclick="shangchuan()"><br><br>
            &nbsp;&nbsp;&nbsp;
        </label>

        <label>
            <span>腾讯视频地址:</span>
            <input type="text" name="video" class="video" id="video">

        </label><br>
        <!-- <label>
             <input type="text" name="thumbnail" class="thumbnail" id="thumbnail" style="display: none">
         </label>-->
        <label>
            <span>上报人:</span>
            <input type="text" name="report" class="report" id="report">
        </label>
        <label>
            <span>联系人: </span>
            <input type="text" name="username" class="username" id="username">
        </label>
        <label>
            <span>联系电话:</span>
            <input type="number" name="userphone" class="userphone" id="userphone">
        </label>


        <input type="button" class="button" value="保存" onclick="baocun()">

    </form>
</div>

#end
<!--
</body>
</html>-->
